<script setup>

import { fetchDict } from "@/utils/dict.js";

const props = defineProps({
  /** 字典类型 */
  dictType: {
    type: String,
    required: true,
  },

  /**当前双向数据绑定的值 */
  value: {
    type: String
  },

});


const list = ref();

const emit = defineEmits(['update:value']);

fetchDict(props.dictType).then((res)=>{
  list.value = res;
})

const valueId = computed({
  get: () => props.value,
  set: (val) => {
    emit('update:value', val)
  }
});

</script>

<template>
  <el-select v-model="valueId" style="width: 100%;" clearable>
    <el-option v-for="u in list" :key="u.value" :label="u.label" :value="u.value"></el-option>
  </el-select>
</template>

<style scoped lang="scss">

</style>